package com.itheima.controller;

import com.itheima.domain.vo.PageResult;
import com.itheima.domain.vo.Result;
import com.itheima.service.LogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "日志管理", description = "系统日志管理相关接口")
@Slf4j
@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private LogService logService;

    /**
     * 日志分页查询
     * 
     * @param page
     * @param pageSize
     * @return
     */
    @Operation(summary = "分页查询日志", description = "分页查询系统操作日志")
    @GetMapping("/page")
    public Result page(@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
            @Parameter(description = "页面大小") @RequestParam(defaultValue = "10") Integer pageSize) {
        log.info("分页查询,当前页码:{},每页条数:{}", page, pageSize);
        PageResult pageResult = logService.pageQuery(page, pageSize);
        return Result.success(pageResult);
    }
}